package com.daohang361.imqq.encoder;

import com.daohang361.imqq.Asycore.QQUser;
import com.daohang361.imqq.protocol.QQ2011;
import com.daohang361.imqq.tool.ByteArray;
import com.daohang361.imqq.tool.MyByteSendArray;
import com.daohang361.imqq.tool.MyUtil;

public class Encoder012C implements InterfaceEncoder {
	private boolean ignore=false;
	@Override
	public byte[] encode(QQUser myqq, int command) {
		
		ByteArray myByte = new MyByteSendArray();
		myByte.putInt(QQ2011.QQ_PROTOCOL_PACKAGE_HEAD);
		myByte.putInt(QQ2011.QQ_PROTOCOL_VERSION);
		myByte.putHex("012C");
		myByte.putInt(myqq.getPakage());//包增长应该在接受到此包后
		myByte.putInt(myqq.getQq());
		myByte.putByte(QQ2011.QQ_CONTEX_FIX_12);
		myByte.saveThis();//保存此段作为第0段
		if(myqq.getLogintimes()==6)
			myByte.putByte(QQ2011.QQ_CONTEX_FIX_012C_1);
		else
			myByte.putByte(QQ2011.QQ_CONTEX_FIX_012C_2);
		myByte.putByte(MyUtil.getRandom(16));
//		myByte.putByte(QQ2011.QQ_CONTEX_FIX_012C_FIRST);
		myByte.saveThis();//保存此段作为第一段
		
		myByte.teaThis(1, 1,myqq.getAttr("SessionKey"));//加密第一段到第一段
		myByte.putInt(QQ2011.QQ_PROTOCOL_PACKAGE_TAIL);
		myByte.saveThis();//保存此段作为第二段
		return myByte.getByteList();//返回完整的package
		
	}

	@Override
	public boolean getIgnore() {
		
		return ignore;
	}
	
	@Override
	public void setIgnore(boolean ignore) {
		this.ignore=ignore;
	}

	@Override
	public Object invoke(Object... o) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public byte[] encode(QQUser myqq, int command, Object... o) {
		// TODO Auto-generated method stub
		return null;
	}
}
